package org.ehais.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;

/**
 * websocket配置
 */
@Configuration
public class WebSocketConfig {
	//服务端配置
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
    	System.out.println("ServerEndpointExporter");
        return new ServerEndpointExporter();
    }
	//客户端配置
    @Bean
    public WebSocketContainer webSocketContainer() {
    	System.out.println("WebSocketContainer");
        WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer();
        webSocketContainer.setDefaultMaxSessionIdleTimeout(300000L);
        return webSocketContainer;
    }
}
